<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
    <title>新增图书</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    
    <script src="../../scripts/boot.js" type="text/javascript"></script>
    

    <style type="text/css">
    html, body
    {        
        padding:0;
        margin:0;
        border:0;
        height:100%;
        overflow:hidden;
    }
    </style>
</head>
<body>    
     
    <form id="form1" method="post">
        <fieldset style="border:solid 1px #aaa;padding:3px;">
            <legend >新增图书信息</legend>
            <div style="padding:5px;">
        <table>
            <tr>
                <td style="width:80px;">图书名称:</td>
                <td style="width:150px;">    
                    <input name="bookname" class="mini-textbox" required="true" requiredErrorText="忘写名字"/>
                </td>
                <td style="width:80px;">出版社：</td>
                <td >                        
                    <input name="publisher" class="mini-textbox" required="true" emptyText="请输入出版社"/>
                        
                </td>
                
            </tr>
            <tr>
                <td >作者：</td>
                <td >    
                    <input name="author" class="mini-textbox" required="true" />
                </td>
                <td >图书类别：</td>
                <td >    
                    <input name="booktype" class="mini-combobox" url="../../data/bookType.txt" 
                    showNullItem="true" nullItemText="请选择类别" allowInput="true"/>
                </td>
            </tr>
            <tr>
                <td >剩余数量：</td>
                <td >    
                    <input name="remain" class="mini-spinner"  minValue="0" maxValue="2147483647" increment=1/>
                </td>
            </tr>          
        </table>            
            </div>
        </fieldset>
        <div style="text-align:center;padding:10px;">               
            <a class="mini-button" onclick="onOk" style="width:60px;margin-right:20px;">确定</a>       
            <a class="mini-button" onclick="onCancel" style="width:60px;">取消</a>       
        </div>        
    </form>
    <script type="text/javascript">
        mini.parse();


        var form = new mini.Form("form1");

        function SaveData() {
            var o = form.getData();            

            form.validate();
            if (form.isValid() == false) {
            	return;
            }
            var json = mini.encode(o);
            $.ajax({
                url: "/bookinfoaddaction",
		        type: 'post',
                data: { data: json },
                cache: false,
                success: function (text) {
                    mini.alert(text,"提示：",function(){
                    	 CloseWindow("save");
                    });
                },
                error: function (jqXHR, textStatus, errorThrown) {
                    alert(jqXHR.responseText);
                    CloseWindow();
                }
            });
        }

         function GetData() {
            var o = form.getData();
            return o;
        }
        function CloseWindow(action) {            
            if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
            else window.close();            
        } 
        function onOk(e) {
            SaveData();
        }
         function onCancel(e) {
            CloseWindow("cancel");
        }


    </script>
</body>
</html>